package com.zhou.framework.pool;

import lombok.extern.slf4j.Slf4j;

/**
 * 全局监听器
 */
@Slf4j
public class DefaultThreadTrigger implements ThreadTrigger{

    @Override
    public void beforeExecute(Thread t, Runnable r) {
        log.info("线程【"+Thread.currentThread().getName() + "】开始执行...");
    }

    @Override
    public void afterExecute(Runnable r, Throwable t) {
        if(t != null){
            log.error("线程【{}】执行异常",Thread.currentThread().getName(),t);
        }else{
            log.info("线程【{}】执行结束",Thread.currentThread().getName());
        }
    }

    @Override
    public void beforeShutdown() {
        log.info("线程池退出");
    }
}
